/*
 * This file is part of PDBEdit.
 * 
 * PDBEdit is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * PDBEdit is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with PDBEdit.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * Creation date : 31/08/2010
 * Copyright (c) Guerfyld 2010. All rights reserved.
 * http://......
 */
package pdbfile;

/**
 * The PDBView class manage PilotDB view
 *
 * @author guerfyld
 * @version 1.0
 */
public class PDBView {
	private String name;
	private int[] colNum;
	private int[] colWidth;
	private PDBColumn[] columns;

	public static final int DEFAULTWIDTH = 80;

	/**
	 * Constructor
	 *
	 * @param nbCols	number of columns in view
	 */
	public PDBView(PDBColumn[] cols, String name) {
		this(cols, name, new int[cols.length], new int[cols.length]);
		int nbCols = cols.length;
		for(int i=0; i<nbCols; i++) {
			colNum[i]=i;
			colWidth[i]=DEFAULTWIDTH;
		}
	}

	/**
	 * Constructor
	 *
	 * @param name		view name
	 * @param colNum	table of column number in view
	 * @param colWidth	table of column width in view
	 */
	public PDBView(PDBColumn[] cols, String name, int[] colNum, int[] colWidth) {
		this.columns = cols;
		this.name = name;
		this.colNum = colNum;
		this.colWidth = colWidth;
	}

	/**
	 * Get column number
	 *
	 * @return	Number of specified column
	 */
	public int getColNum(int pos) {
		return colNum[pos];
	}

	/**
	 * Get column width
	 *
	 * @return	width of specified column
	 */
	public int getColWidth(int pos) {
		return colWidth[pos];
	}

	/**
	 * Get column type
	 */
	public int getColType(int pos) {
		int nCol = colNum[pos];
		return columns[nCol].type;
	}

	/**
	 * Get number of column in view
	 *
	 * @return	Number of column in view
	 */
	public int getNbCol() {
		return colNum.length;
	}

	/**
	 * Get view name
	 *
	 * @return 	view name
	 */
	public String getName() {
		return name;
	}

        /**
         * Set column width
         */
        public void setColWidth(int pos, int width) {
                colWidth[pos] = width;
        }
}